import Vue from 'vue'
import Router from 'vue-router'
import permission from './permission.js'
import exampleRouter from './example.js'

Vue.use(Router)

const routerMap = new Router({
  routes: [
    exampleRouter,
    {
      path: '/',
      redirect: '/example',
      meta: { hidden: true }
    },
    {
      path: '/error',
      name: 'error',
      component: () => import('../components/layout/'),
      meta: { title: '错误' },
      children: [
        {
          path: '404',
          component: () => import('../pages/404'),
          meta: { title: '404' }
        }
      ]
    }
  ]
})

routerMap.beforeEach(permission.beforeEachHandler)
routerMap.afterEach(permission.afterEachHandler)

export default routerMap
export const constantRouterMap = []
export const asyncRouterMap = []
